﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;

public partial class Pages_Usercenter_ChangeMyData : System.Web.UI.Page
{
    public Tuan.Model.UserInfo user = new Tuan.Model.UserInfo();
    //public string Nickname;
    
    protected void Page_Load(object sender, EventArgs e)
    {

        hdUserName.Value = User.Identity.Name;
        user = (new Tuan.BLL.UserInfo()).GetModel(User.Identity.Name);
        if (!IsPostBack)
        {
            name.Value = user.Nickname;
            if (user.Sex.Trim() == "男")
            {
                male.Checked = true;
            }
            else if (user.Sex.Trim() == "女")
            {
                female.Checked = true;
            }
        }
    }

    protected void submitChange(object sender, EventArgs e)
    {
        user.Nickname = name.Value;
        if (male.Checked == true)
        {
            user.Sex = "男";
        }
        else if(female.Checked==true)
        {
            user.Sex = "女";
        }
        Tuan.BLL.UserInfo updatauser = new Tuan.BLL.UserInfo();
        try
        {
            updatauser.Update(user);
            success.Visible = true;
        }
        catch (Exception er)
        {
            Response.Write(er.ToString());
        }
       // Response.Redirect("ChangeMyData.aspx");
    }
}
